﻿using MVVM.NotifyPropertyChanged.ViewModels;

namespace MVVM.NotifyPropertyChanged.Views
{
    public partial class LoginView : Form
    {
        private readonly LoginViewModel _viewModel;
        public LoginView(LoginViewModel viewModel)
        {
            InitializeComponent();
            _viewModel = viewModel;
            tbUsername.DataBindings.Add("Text", _viewModel, "Username");
            tbPassword.DataBindings.Add("Text", _viewModel, "Password");

            lbMsgUsername.DataBindings.Add("Text", _viewModel, "Username");
            lbMsgPassword.DataBindings.Add("Text", _viewModel, "Password");
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (_viewModel.LoginCommand.Execute("test"))
            {
                this.Hide();
            }
        }
    }
}
